package top.superflow.flow.runtime.processprovider

import top.superflow.core.metadata.MetadataAble
import top.superflow.core.utils.PojoUtils
import top.superflow.flow.config.Identifiable
import top.superflow.flow.runtime.Providable
import top.superflow.flow.runtime.resource.RuntimeResource

import scala.beans.BeanProperty

trait RuntimeProcessProvider extends Providable{

  @BeanProperty
  var dependencies : Map[String, RuntimeResource] = _

  def provide(metadata: MetadataAble) : OriginalProcessProxy

  def contain(processKey : String) : Boolean

  def getResource(resourceKey : String) : RuntimeResource

  def setResource(resourceKey : String, runtimeResource: RuntimeResource): Unit ={
    val field = PojoUtils.getField(this, resourceKey)

    if(field != null){
      if(runtimeResource.getClass.isAssignableFrom(field.getType)){
        PojoUtils.setField(field, this, runtimeResource)
      }
    }
  }
}
